<?php


class dbaLtdArticle {

 function dbaLtdArticle (&$dba) {
    $this->dba = $dba;
 }

 function getVisibleArticle ($id){
   $check = $this->dba->query("select * from ".$this->dba->tableforwarder."_shopArt where id=$id AND visible='Y';");
   return $this->dba->fetch_row_Array();
 }

 function getVisibleArticlesArrayFieldsByCatName ($name,$fields){
    $count = count($fields);
    for ($i = 0; $i < $count; $i++){
      if ($i == $count-1){
        $fieldStr .= $this->dba->tableforwarder."_shopArt.".$fields[$i];
      } else {
        $fieldStr .= $this->dba->tableforwarder."_shopArt.".$fields[$i].",";
      }
    }
   $check  = $this->dba->query("select $fieldStr from ".$this->dba->tableforwarder."_shopArt,".$this->dba->tableforwarder."_shopCat,".$this->dba->tableforwarder."_shopCatArt where ".$this->dba->tableforwarder."_shopCat.name = '$name' AND ".$this->dba->tableforwarder."_shopArt.id = art_id AND ".$this->dba->tableforwarder."_shopCat.id = cat_id;");
   return $this->dba->fetch_rows_Array();
 }

 // mwst ganz am anfang
 function getVisibleArticlesArrayFieldsByCat ($cat,$fields){
    $count = count($fields);
    for ($i = 0; $i < $count; $i++){
      if ($fields[$i] == "mwst"){
         $mwst_flag = true;
	 continue;
      }
      if ($mwst_flag && ($fields[$i] == 'id')){
        $fields[$i] = $this->dba->tableforwarder."_shopArt.id";
      }
      if ($i == $count-1){
        $fieldStr .= $fields[$i];
      } else {
        $fieldStr .= $fields[$i].",";
      }
    }
   if ($mwst_flag){
      $request = "select $fieldStr,satz AS mwst from ".$this->dba->tableforwarder."_shopArt,".$this->dba->tableforwarder."_shopmwst,".$this->dba->tableforwarder."_shopCatArt where art_id=".$this->dba->tableforwarder."_shopArt.id AND cat_id=$cat AND visible='Y' AND mwst_id=".$this->dba->tableforwarder."_shopmwst.id;";
   } else {
      $request = "select $fieldStr from ".$this->dba->tableforwarder."_shopArt,".$this->dba->tableforwarder."_shopCatArt where art_id=id AND cat_id=$cat AND visible='Y';";
   }
   $check  = $this->dba->query($request);
   return $this->dba->fetch_rows_Array();
 }

 // mwst ganz am anfang
 function getVisibleArticleFields ($id,$fields){
    $count = count($fields);
    for ($i = 0; $i < $count; $i++){
      if ($fields[$i] == "mwst"){
         $mwst_flag = true;
	 continue;
      }
      if ($fields[$i] == 'id'){
        $fields[$i] = $this->dba->tableforwarder."_shopArt.id";
      }
      if ($i == $count-1){
        $fieldStr .= $fields[$i];
      } else {
        $fieldStr .= $fields[$i].",";
      }
    }
   if ($mwst_flag){
      $request = "select $fieldStr,satz AS mwst from ".$this->dba->tableforwarder."_shopArt,".$this->dba->tableforwarder."_shopmwst where ".$this->dba->tableforwarder."_shopArt.id=$id AND visible='Y' AND mwst_id=".$this->dba->tableforwarder."_shopmwst.id;";
   } else {
      $request = "select $fieldStr from ".$this->dba->tableforwarder."_shopArt where id=$id AND visible='Y';";
   }
   $check = $this->dba->query($request);
   return $this->dba->fetch_row_Array();
 }
// ende storefront functionen

}

?>
